#!/bin/sh

# GTA San Andreas initialization script

# GAME variables

export WINEPATH="$HOME/Wine/Versions/tkg-3.21-x86_64" &&
export WINEPREFIX="$HOME/Wine/Games/gta-sa" &&
export GAMEPATH="$WINEPREFIX/gta-sa" &&
export GAMEEXE="gta_sa.exe" &&

# WINE variables
export PATH=$WINEPATH"/bin" &&
export WINELOADER=$WINEPATH"/bin/wine" &&
export LD_LIBRARY_PATH=$WINEPATH"/lib" &&
export WINESERVER=$WINEPATH"/bin/wineserver" &&
export WINEDLLPATH=$WINEPATH"/lib/wine/fakedlls" &&
export WINEDEBUG="-all" &&

# Execute game

cd "$GAMEPATH" &&

screen=$(echo 'Windowed''\n''Fullscreen' | /usr/bin/dmenu -p 'Screen mode:' -i -fn "xos4 Terminus:size=10" -nb '#282828' -nf '#ebdbb2' -sb '#458588' -sf '#282828')

if [ -z "$screen" ]; then
exit
elif [ $screen = Windowed ]; then
$WINELOADER explorer /desktop=gta-sa,1024x768 "$GAMEPATH"/"$GAMEEXE" 
else
$WINELOADER explorer /desktop=gta-sa,1920x1080 "$GAMEPATH"/"$GAMEEXE"
fi


